<!-- 批量编辑属性 -->
<template>
  <div class="substitution-part-table" v-loading="pageLoading">
    <!-- 操作栏 -->
    <ty-plm-tool-bar :options="toolbarOptions" v-model="toolbarOptions.keyword" @refresh="handleClearKeyword"
      @focus="handleFocusValue" @blur="handleBlurValue" @clear="handleChangeValue" @search="handleChangeValue">
      <template #fontBtn>
        <div>
          <ty-plm-button :options="btnOptions('add')" @click="handleClickAddRow" />
          <ty-plm-button :options="btnOptions('delete')" @click="handleResetDelete" />
        </div>
      </template>
    </ty-plm-tool-bar>
    <div :class="['box-content-class', `box-table-${queryType}--class`]" v-click-outside="onClickOutside">
      <ty-plm-grid ref="editVxeTable" :options="gridOptions" @checkbox-change="handleSelectionChange"
        @checkbox-all="handleAllSelect" @edit-activated="handleEditActivated">
        <!-- 默认列 -->
        <template v-for="(item, index) in defaultColumns" #[item.prop]="{ row }" :key="index + item.prop + item.$key">
          <div>
            <span v-if="item.prop == 'typeIcon'">
              <em v-if="row.typeIcon" :class="[row.typeIcon, 'mgr4']" />
              <em :class="`iconfont ${showMark[row.lockstateinfo]} font-14 mgr4`" />
            </span>
            <ty-plm-tooltip-value v-if="item.prop != 'typeIcon'"
              :options="{ content: getLabelByColumn(row, item.prop, item) }">
              <span>{{ getLabelByColumn(row, item.prop, item) }}</span>
            </ty-plm-tooltip-value>
            <!-- 校验提示 -->
            <el-tooltip v-if="row[`${item.prop}MsgTips`]" effect="dark" :content="row[`${item.prop}MsgTips`]"
              placement="top">
              <em class="iconfont icon-a-yuanxinghong batch-edit-attribute-rules--msg" />
            </el-tooltip>
          </div>
        </template>
        <!-- 可编辑列 -->
        <template v-for="(item, index) in editColumns" #[editItem(item)]="{ row }">
          <div v-if="!item.isIbaProperty" :key="index + item.prop + item.$key">
            <!-- 输入框 -->
            <ty-plm-input v-if="['input', 'tyInput'].indexOf(item.elementType) > -1" style="width: 100%" :options="{
              placeholder: $t('pls'),
              disabled: item.readOnly || disabled
            }" v-model="row[item.prop]" @input="val => handleInputChange(row, item.prop, val)" size="small" />
            <!-- 选择框 -->
            <ty-plm-combo v-if="item.elementType == 'tySelect'"
              :options="{ ...item.editRender.options, disabled: item.readOnly || disabled }" v-model="row[item.prop]" />
            <!-- 校验提示 -->
            <el-tooltip v-if="row[`${item.prop}MsgTips`]" effect="dark" :content="row[`${item.prop}MsgTips`]"
              placement="top">
              <em class="iconfont icon-a-yuanxinghong batch-edit-attribute-rules--msg" />
            </el-tooltip>
          </div>
          <!-- iba属性 -->
          <div v-else :key="index + item.prop + item.$key">
            <commonAttributeTable :ibaPropObj="item" :row="row" :unitList="unitList" :key="index" :isPermission="false"
              :objOtypeAttrObj="{ ibaForm: '' }" :ibaFormList="getIbaFormList(item)"
              @updateIbaValues="updateMixinsJsIbaValues" />
          </div>
        </template>
      </ty-plm-grid>
    </div>
 
    <!-- 查询添加 -->
    <ty-plm-dialog v-model="queryAddObj.dialogVisible" :options="{
      title: $t('basic.label.queryAdd'),
      isDrawer: true,
      appendToBody: true,
      customClass: 'query-add-dialog'
    }" :size="1200" @doConfirm="handleSubmitAddObj" @closeDialog="val => (queryAddObj.dialogVisible = val)">
      <query-add v-if="queryAddObj.dialogVisible" ref="queryAddRef" :addKey="queryAddObj.addKey"
        :defaultSelectionList="queryAddObj.defaultSelectionList" :options="queryAddObj.options"
        :modulekeyParam="queryAddObj.modulekeyParam"></query-add>
    </ty-plm-dialog>
  </div>
</template>
<script setup>
onMounted(()=>{
  console.log('我是替代规则替换后的页面')
});
const commonAttributeTable = window.tyRoot.getExportResource('src/modules/pdm/business-module/part/components/common-attribute-table.vue').default;
import basic from '@common/basic';
import {
  createProps,
  createEmits,
  useSubstitutionPartTable,
  useOverride
} from '../../../../composables/substitution-part-table.js';
// const {createProps} = 
// window.tyRoot.getExportResource('src/modules/pdm/business-module/part/composables/substitution-part-table.js')
// const {createEmits} = 
// window.tyRoot.getExportResource('src/modules/pdm/business-module/part/composables/substitution-part-table.js')
// const {useSubstitutionPartTable} = 
// window.tyRoot.getExportResource('src/modules/pdm/business-module/part/composables/substitution-part-table.js')
// const {useOverride} = 
// window.tyRoot.getExportResource('src/modules/pdm/business-module/part/composables/substitution-part-table.js')

const queryAdd = basic.getExportResource('src/basic/business-modules/query-add/query-add.vue').default;
defineOptions({
  name: 'substitutionPartTable'
});
const props = defineProps(createProps());
const emits = defineEmits(createEmits());
 
const {
  toolbarOptions,
  checkboxConfig,
  originGridOptionsColumns,
  tableColumns,
  showMark,
  modulekeyParam,
  pageLoading,
  unitList,
  substitutionTableConfig,
  isSaveData,
  selection,
  updateRecordsParam,
  allTableData,
  tableSourceData,
  editVxeTable,
  gridOptions,
  btnOptions,
  defaultColumns,
  editColumns,
  editItem,
  selectionOrRowList,
  getLabelByColumn,
  getIbaFormList,
  updateMixinsJsIbaValues,
  initData,
  getTableData,
  bindingPropertiesItem,
  getDefaultColumnByViewNameToInvokeApi,
  getDefaultColumnByViewName,
  handleFormDataColumn,
  handleSelectionChange,
  handleAllSelect,
  cellClassName,
  cellStyle,
  handleClickAddRow,
  handleResetDelete,
  getTableDataList,
  getNeedSaveBatchOperateData,
  getUpdateRecordsTableData,
  handleFocusValue,
  handleClearKeyword,
  handleBlurValue,
  handleChangeValue,
  queryAddObj,
  handleSubmitAddObj,
  queryAddRef,
  getInsertPartList,
  resetFieldData,
  handleInputChange,
  handleEditActivated,
  onClickOutside
} = (useOverride || useSubstitutionPartTable)(props, emits);
defineExpose({
  getNeedSaveBatchOperateData,
  resetFieldData
});
</script>
<style lang="scss" scoped>
.substitution-part-table {
  width: 100%;
  overflow: hidden;

  :deep(.ty-plm-bool-bar) {
    padding-top: 6px;

    .el-input__wrapper {
      box-shadow: 0 0 0 1px black inset !important;
    }
  }

  .popover-help--tips {
    margin-right: 8px;
  }

  .check-total--class {
    margin-left: 12px;
    font-size: 12px;
  }

  :deep(.ui-ty-button--icon) {
    &.changeColorCls {
      border-color: blue;
      color: blue !important;
    }
  }

  .left-bar--class {
    margin-left: 8px;
  }

  :deep(.vxe-grid) {
    // 避免ctrl、shift多选时，出现大片蓝色
    user-select: none;
  }

  .box-content-class {
    width: 100%;
    height: calc(100% - 40px);

    :deep(.vxe-table--body-wrapper .requiredClass:after) {
      content: '*';
      top: 0;
      right: 1px;
      position: absolute;
      font-size: 12px;
      font-weight: bolder;
    }

    :deep(.el-select .el-input__inner) {
      height: 28px !important;
      line-height: 28px !important;
    }


  }
}
</style>
<style lang="scss">
.batch-edit-attribute-rules--msg {
  position: absolute;
  right: -4px;
  top: 0px;
  font-size: 6px !important;
  color: red;
  width: 8px;
  height: 26px;
  line-height: normal;
  text-align: center;
  margin: 2px;
}
</style>
